import { createRouter, createWebHistory } from 'vue-router';
import Login from "@/views/login.vue";
import Register from "@/views/register.vue";
import Product from "@/views/product/sousuo.vue";
import Productdetail from "@/views/product/productdetail.vue";
import CartPage from "@/views/buy/cartpage.vue"; // 购物车页面
import CheckoutPage from "@/views/buy/checkoutpage.vue"; // 结算页面

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/login',
            name: 'Login',
            component: Login,  // 登录页面路由配置
        },
        {
            path: '/register',
            name: 'Register',
            component: Register,  // 注册页面路由配置
        },
        {
            path: '/product',
            name: 'Product',
            component: Product,  // 商品列表页
        },
        {
            path: '/product/:productId',
            name: 'Productdetail',
            component: Productdetail, // 商品详情页
        },
        {
            path: '/cartpage',
            name: 'Cartpage',
            component: CartPage,  // 购物车页面
        },
        {
            path: '/checkoutpage',
            name: 'Checkoutpage',
            component: CheckoutPage,  // 结算页面
        },
        {
            path: '/',
            name: 'index',
            component: () => import('../views/index/sousuo.vue'),
            redirect: '/official',
            children: [
                {
                    path: 'official',
                    name: 'official',
                    component: () => import('../views/index/official.vue'),
                },
            ]
        },
    ],
});

export default router;
